package com.example;

import com.example.entity.User;
import com.example.framework.annotation.HelloScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.Map;

@SpringBootApplication
@HelloScan(basePackageName = "com.example.service")
public class SpringHelloScanApplication  implements ApplicationRunner{

	@Autowired
	private ApplicationContext applicationContext;

	public static void main(String[] args) {
		SpringApplication.run(SpringHelloScanApplication.class, args);
	}


	@Override
	public void run(ApplicationArguments args) throws Exception {
		Map<String, User> beanMap = applicationContext.getBeansOfType(User.class);
		beanMap.forEach((key,value)-> System.out.println("key:"+key+"-->value:"+value));
	}
}
